﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class Features_DestoyComponet : BattleEventComponent
    {
        public override BattleEventType[] EventType { get; set; } = new BattleEventType[] { BattleEventType.AttackSuccess};

        public override Task RunEvent(BattleEventType eventType, FightModel fightModel, params object[] param)
        {
            DamageInfo damageInfo = param[0] as DamageInfo;
            BattleCard battleCard = GetEntity<BattleCard>();
            if (damageInfo.AttackCard == battleCard)
            {
                SearchInfo searchInfo = new SearchInfo
                {
                    Condition = (x) =>
                    {
                        return (x.Count == 1);
                    },
                    MaxChooseNum=1,
                    OnSure = (x) =>
                    {
                        x[0].Move(x[0].Owner[CardPlace.Cemetery]);
                    },
                };
                await BattleEventWatcherComponent.Single.RunEvent(BattleEventType.ShowWindow, fightModel, WindowType.Search, searchInfo);
            }
        }
    }
}
